//
//  TabBarController.m
//  ai2ban
//
//  Created by mac book pro on 2018/1/6.
//  Copyright © 2018年 mac book pro. All rights reserved.
//

#import "TabBarController.h"
#import "HomeController.h"
#import "ShopController.h"
#import "JiFenController.h"
#import "MeController.h"
#import "NavgationController.h"
@interface TabBarController ()

@end

@implementation TabBarController


- (void)viewDidLoad {
    [super viewDidLoad];
    [self addSubViewsControllers];
    [self customTabbarItem];
    
    
}
-(void)addSubViewsControllers{
    
    NSArray *classControllers = @[@"HomeController",@"ShopController",@"JiFenController",@"MeController"];
    NSMutableArray *conArr = [NSMutableArray array];
    
    for (int i = 0; i < classControllers.count; i ++) {
        Class cts = NSClassFromString(classControllers[i]);
        UIViewController *vc = [[cts alloc] init];
        NavgationController *naVC = [[NavgationController alloc] initWithRootViewController:vc];
        [conArr addObject:naVC];
    }
    self.viewControllers = conArr;
}
-(void)customTabbarItem{
    NSArray *normalImages = @[@"home", @"shop", @"jifen",@"me"];
    NSArray *selectImages = @[@"home-fill", @"shop-fill", @"jifen-fill",@"me-fill"];
    NSArray *title = @[@"首页",@"商家",@"星星商城",@"我的"];
    for (int i = 0; i < normalImages.count; i++) {
        UIViewController *vc = self.viewControllers[i];
        UIImage *normalImage = [[UIImage imageNamed:normalImages[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        UIImage *selectImage =[[UIImage imageNamed:selectImages[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        vc.tabBarItem = [[UITabBarItem alloc] initWithTitle:title[i] image:normalImage selectedImage:selectImage];
        
//        [vc.tabBarItem setTitleTextAttributes:[NSDictionary
//                                               dictionaryWithObjectsAndKeys: [UIColor colorWithRed:51/255.0 green:207/255.0 blue:137/255.0 alpha:1],
//                                               NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
        [vc.tabBarItem setTitleTextAttributes:[NSDictionary
                                               dictionaryWithObjectsAndKeys: mainColor,
                                               NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
    }
    
    

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
